package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.DailyQuery;
import cn.wolfcode.trip.base.query.TravelQuery;
import cn.wolfcode.trip.base.service.IDailyService;
import cn.wolfcode.trip.base.service.IStrategyDetailService;
import cn.wolfcode.trip.base.service.ITravelService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("seekall")
public class SeekAllController {
    @Autowired
    private ITravelService travelService;

    @Autowired
    private IStrategyDetailService strategyDetailService;

    @Autowired
    private IDailyService dailyService;

    @PostMapping(value = "selecttravelbyid",produces = "application/json;charset=utf-8")
    public JSONResult selecttravelbyid(TravelQuery qo){
        //查询已发布的
        qo.setIsPublic(true);
        PageInfo list = travelService.query(qo);
        JSONResult json = new JSONResult();
        json.setResult(list);
        return json;
    }

    @PostMapping(value = "selectstrategybyid",produces = "application/json;charset=utf-8")
    public JSONResult selectstrategybyid(TravelQuery qo){
        PageInfo list = strategyDetailService.query(qo);
        JSONResult json = new JSONResult();
        json.setResult(list);
        return json;
    }

    @PostMapping(value = "selectdailybyid",produces = "application/json;charset=utf-8")
    public JSONResult selectDailybyid(DailyQuery qo){
        PageInfo list = dailyService.query(qo);
        JSONResult json = new JSONResult();
        json.setResult(list);
        return json;
    }
}
